package org.chengn.level_easy.context1185;

/**
 * @Title: Context1185
 * @Author ChengN
 * @Package org.chengn.level_easy.context1185
 * @Date 2023/12/30 2:15
 * @description: 一周中的第几天
 */
public class Context1185 {
    String[] weeks = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
    int[] months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    public String dayOfTheWeek(int day, int month, int year) {
        int days = 0;
        for (int i = 1970; i < year; ++i) {
            days += isRun(i) ? 366 : 365;
        }
        if (isRun(year)) months[1] = 29;
        for (int i = 0; i < month - 1; ++i) {
            days += months[i];
        }
        days += day;

        return weeks[days % 7];
    }

    boolean isRun(int year) {
        if (year % 100 == 0 && year % 400 == 0 || year % 100 != 0 && year % 4 == 0) {
            return true;
        }
        return false;
    }
}
